﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>角色维护</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var $grid;
        var maiheight = 500;
        var $selectRow ={ J_ID: 0, A_ID: 0, A_NAME: '', A_LEVEL: 0, R_ID: 0, R_NAME: '', R_POWER: 0, R_REMARK: '' };
        var vUrl = null;
        $(function () {
            maiheight = $(window).height();


            //显示gride
            $grid = $("#maingrid").ligerGrid({
                columns: [
               { display: '序号', align: 'left', width: 40, type: 'int', isSort: false,
                   render: function (item, i) {
                       i = i + 1;
                       return i;
                   }
               },
                { display: '职务名称', name: 'name', align: 'left', width: 80 },
                { display: '备注', name: 'remark', width: 200 },
                { display: '创建日期', name: 'date', type: 'date', dateFormat: "yyyy-MM-dd", width: 80 },

                 { display: '状态', name: 'power', isSort: false, width: 60,
                     render: function (item) {
                         if (item.power == 0) return "普通员";
                         else if (item.power == 1) return "管理员";
                         else if (item.power == 2)
                             return "公共";
                     }
                 },
                  { display: '删除', name: 'id', isSort: false, width: 60,
                      render: function (item) {
                          return "<a   onclick='deleteItem(" + item.id + ",&quot;" + item.name + "&quot;)' href='javascript:' >删除</a>";
                      }
                  }


                ],
                parms: [{ name: 'rolName', value: $("#txtrolName").val()}],
                dataAction: 'server', pageSize: 20,
                url: '../WebServer/MainAdmin.ashx?Action=RoleList',
                sortName: 'name',
                width: '95%', height: '95%',
                onDblClickRow: function (data, rowindex, rowobj) {
                    if (data.id != null) {
                        $selectRow.R_ID = data.id;
                        $selectRow.R_NAME = data.name;
                        $selectRow.R_POWER = data.power;
                        $selectRow.R_REMARK = data.remark;

                        ShowDialog("admin/EditeRole.htm", "编辑", 500, 400);
                    }
                }

            });
        });

      
        function Search() {
            loadGrid();
        }

        function loadGrid() {
            if (!$grid) return;
            $("tbody > tr", $grid.gridbody).each(function () {
                $(this).remove();
            });
            $grid.setOptions({ parms: [{ name: 'rolName', value: $("#txtrolName").val() }], newPage: 1, Rows: [], Total: 0 });   //设置数据参数

            $grid.loadData(true); //加载数据

        }

        function AddRole() {
            ShowDialog("admin/AddRole.htm", "编辑", 500, 400);
        }

        function deleteItem(vl, vname) {
           
            jqConfirm("你确定删除[" + vname + "]吗？", "提示", function (v) {
                if (v == 'ok') {
                    $("body").mask("数据处理中，请稍候......");
                    $.getJSON('../WebServer/MainAdmin.ashx?Action=DeleteRoleItem', { id: vl }, function (data) {
                        $("body").unmask();
                      
                        if (data.IsSuccess == 1) {
                            showAlertOk("删除成功");
                            loadGrid();
                        } else {
                            if (data.IsSuccess == -99) {
                                showErrorTip("该角色已经被使用不能删除");
                            }else
                            showErrorTip(data.Msg);

                        }
                    }); //end ajax
                } //end if

            });
        }


    </script>
    <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
    </style>
  
</head>
<body>


         
            <div  position="center" title="">
             <div id="toptoolbar"></div> 
            <div class="l-panel-search">
                <div class="l-panel-search-item">
                   <span>名称：</span>
                </div>
                <div class="l-panel-search-item">
                    <input id="txtrolName" type="text" ltype="text" />
                </div>
                 
                <div class="l-panel-search-item">
                    <a  class="l-button" style="width:60px; float:left; margin-left:10px;"   onclick="Search()">查询</a>&nbsp;
                   
                </div>

                  <div class="l-panel-search-item">
                    <a  class="l-button" style="width:60px; float:left; margin-left:10px;"   onclick="AddRole()">添加角色</a>&nbsp;
                     <label>&nbsp;&nbsp;(<font color="red">注：双击行进行编辑</font>)</label>
                </div>
                
            </div>
               <div id="maingrid">
               </div> 
            </div>
             

   <a id="ExdcleGo" href=""></a>
   <input type="hidden" id="Aid" value="0" />
   <input type="hidden" id="Rid" value="0" />
 
</body>
</html>
